package com.xfly.app.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.ptmall.app.R;
import com.ptmall.app.base.BaseMvpActivity;
import com.ptmall.app.net.api.ApiDataRepository;
import com.ptmall.app.net.base.ApiNetResponse;
import com.ptmall.app.view.TitleBarView;

import java.util.HashMap;
import java.util.Map;

public class WlActivity extends BaseMvpActivity {

    TitleBarView title;

    EditText wlgs,wldh;

    String id;

    Button tj;

    ApiDataRepository apiDataRepository = ApiDataRepository.getInstance();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_txwl);
    }

    @Override
    public void initViews() {
        id = getIntent().getStringExtra("id");
        title = findViewById(R.id.title);
        wlgs = findViewById(R.id.wlgs);
        wldh = findViewById(R.id.wldh);
        tj = findViewById(R.id.tj);

        title.setText("填写发货信息");
    }

    @Override
    public void initEvents() {
        title.setOnTitleBarClickListener(new TitleBarView.TitleBarClickListener() {
            @Override
            public void leftClick() {
                finish();
            }

            @Override
            public void rightClick() {

            }
        });

        tj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sub();
            }
        });
    }

    private void sub(){
        Map<String,String> map = new HashMap<>();
        map.put("orders_id",id);
        map.put("express",wlgs.getText().toString());
        map.put("express_number",wldh.getText().toString());

        apiDataRepository.txwl(map, new ApiNetResponse<Object>() {
            @Override
            public void onSuccess(Object data) {
                showMsg("提交成功");
                finish();
            }
        });
    }
}
